package com.kyrioscraft.cloud.security.core.social.qq.config;

import com.kyrioscraft.cloud.security.core.properties.SecurityProperties;
import com.kyrioscraft.cloud.security.core.social.config.SocialAutoConfigurerAdapter;
import com.kyrioscraft.cloud.security.core.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.social.config.annotation.ConnectionFactoryConfigurer;
import org.springframework.social.connect.ConnectionFactory;


/**
 * @Author kyrioscraft
 * @Date 2018/12/28 15:39
 * @Description //TODO
 **/
@Configuration
@ConditionalOnProperty(prefix = "kyrios.security.social.qq", name = "app-id")
public class QQAutoConfig extends SocialAutoConfigurerAdapter {
    @Autowired
    private SecurityProperties securityProperties;

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        return new QQConnectionFactory(securityProperties.getSocial().getQq().getProviderId(),securityProperties.getSocial().getQq().getAppId(),securityProperties.getSocial().getQq().getAppSecret());
    }
}
